select con.CON_ANNO,con.CON_ID ,valpar.ot_id,valpar.PAROT_ID,valpar.PAROT_DES,trunc(valpar.VER_DTINI) ver_dtini,trunc(valpar.VER_DTFINE) ver_dtfine,
valpar.VPXCO_VAL,valpar.PAROT_VALVIS,valpar.PAROT_POS,valpar.PAROT_ORDSTA,valpar.UM_ID
from v_contratto con,
     v_conubifrn ubi,
     v_attacco atta,
     v_valPARxCUFOT valPAR,
     v_cufot cuf    
where ubi.CON_ANNO = con.CON_ANNO
and atta.az_id='01'
and valpar.az_id='01'
and cuf.az_id='01'

and con.az_id='01'
and ubi.az_id='01'
  and ubi.COn_id=   con.CON_ID
  and ubi.VER_DTFINE = to_date(31129999,'ddmmyyyy') 
  and con.STA_IDSYS =2
  and ubi.STA_IDSYS =2
  and ubi.ATT_ID = atta.ATT_ID
  and ubi.VER_DTFINE = to_date(31129999,'ddmmyyyy') 
  and atta.STA_IDSYS =2
  and atta.VER_DTFINE = to_date(31129999,'ddmmyyyy') 
  and cuf.STA_IDSYS = 2
  and sysdate between cuf.VER_DTini and cuf.VER_DTFINE 
  and cuf.CUF_ID = ubi.CUF_ID
  and cuf.VER_NUM = valpar.cufot_VERNUM 
  and valPAR.STA_IDSYS = 2
  and sysdate between valPAR.VER_DTini and valPAR.VER_DTFINE
 --AND con.RAGF_ID = 5413
--  and valpar.OT_ID =270
  --and valpar.cparot_id in (122)
  
 

       